package com.lin.linchatgpt.mapper;

import com.mybatisflex.core.BaseMapper;
import com.lin.linchatgpt.entity.Image;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *  映射层。
 *
 * @author 15898
 * @since 2023-07-08
 */
@Mapper
public interface ImageMapper extends BaseMapper<Image> {
    @Select("select * from chat_image where user_id = #{userId} and is_delete = 0 order by create_time")
    @ResultType(Image.class)
    List<Image> getImages(@Param("userId") String userId);

    @Insert("insert into chat_image(id,image_id,image_url,user_id,prompt,model,actions,create_time,is_delete) " +
            "values(#{image.id},#{image.imageId},#{image.imageUrl},#{image.userId},#{image.prompt},#{image.model},#{image.actions},now(),#{image.isDelete})")
    int myInsert(@Param("image") Image image);

}
